//
//  GYMakeOrderCell.m
//  GYDemo
//
//  Created by Mrzhang on 2018/4/11.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYMakeOrderCell.h"
#import "Head.h"
@interface GYMakeOrderCell ()<GCAdaptLabelDelegate,UITextFieldDelegate>
@end

@implementation GYMakeOrderCell

#pragma mark - getter and setter
-(UIImageView *)imageIV
{
    if (!_imageIV) {
        _imageIV = [UIImageView new];
        _imageIV.frame = WFCGRectMake(19, 0, 90, 90);
        _imageIV.backgroundColor = Main_Color_BG;
    }
    return _imageIV;
}
-(GCAdaptLabel *)nameLB
{
    if (!_nameLB) {
        _nameLB = [[GCAdaptLabel alloc]initWithMaxWidth:WFCGFloatX(230)];
        _nameLB.x = WFCGFloatX(125);
        _nameLB.y = WFCGFloatY(3);
        _nameLB.width = WFCGFloatX(230);
        _nameLB.font = SYSTEMFONT(13);
        _nameLB.textColor = Main_Color_Black;
        _nameLB.delegate = self;
        _nameLB.numberOfLines=2;
    }
    return _nameLB;
}

-(GCAdaptLabel *)typeLB
{
    if (!_typeLB) {
        _typeLB = [[GCAdaptLabel alloc]initWithMaxWidth:WFCGFloatX(60)];
        _typeLB.x = WFCGFloatX(166);
        _typeLB.y = WFCGFloatY(10);
        _typeLB.width = WFCGFloatX(60);
        _typeLB.height = WFCGFloatY(14);
        _typeLB.font = SYSTEMFONT(10);
        _typeLB.textColor = Main_Color_Red;
        [WFFunctions WFUIaddbordertoView:_typeLB radius:WFCGFloatY(3) width:0.7f color:Main_Color_Red];
        _typeLB.delegate = self;
    }
    return _typeLB;
}


-(UITextField *)countTF
{
    if (!_countTF) {
        _countTF=[[UITextField alloc] init];
        _countTF.backgroundColor=HEXCOLOR(@"#F7F7F7");
        _countTF.delegate=self;
        _countTF.keyboardType=UIKeyboardTypeNumberPad;
        _countTF.textColor=HEXCOLOR(@"#666666");

        _countTF.enabled=NO;
        _countTF.font=SYSTEMFONT(12);

    }
    return _countTF;
}

-(UILabel *)priceLB
{
    if (!_priceLB) {
        _priceLB = [[UILabel alloc]init];
        _priceLB.textColor = HEXCOLOR(@"#FC1B36");
        _priceLB.font = SYSTEMFONT(12);
        _priceLB.x=WFCGFloatX(125);
        _priceLB.y=WFCGFloatY(65);
        _priceLB.width=WFCGFloatX(100);
        _priceLB.height=WFCGFloatY(25);
    }
    return _priceLB;
}

-(UITextField *)priceTF
{
    if (!_priceTF) {
        _priceTF = [UITextField new];
        _priceTF.frame = WFCGRectMake(173, 43.5, 95, 30);
        _priceTF.delegate = self;
        _priceTF.textColor = Main_Color_Black;
        _priceTF.font = SYSTEMFONT(15);
        _priceTF.textAlignment = NSTextAlignmentCenter;
        _priceTF.keyboardType = UIKeyboardTypeNumberPad;
        [WFFunctions WFUIaddbordertoView:_priceTF radius:0 width:0.7f color:Main_Color_BG];
    }
    return _priceTF;
}

-(UILabel *)countLB
{
    if (!_countLB) {
        _countLB = [[UILabel alloc]init];

        _countLB.textColor = HEXCOLOR(@"#666666");
        _countLB.font = SYSTEMFONT(12);
        _countLB.textAlignment = NSTextAlignmentRight;
    }
    return _countLB;
}
-(void)setData:(NSMutableDictionary *)dic
{
    NSDictionary* myDic=[[dic objectForKey:@"datalist"] objectAtIndex:0];
    _nameLB.text = [myDic objectForKey:@"name"];
    
    CGSize nameSize=[WFFunctions WFStrGetSize:_nameLB.text width:WFCGFloatX(230) font:SYSTEMFONT(13)];
    _nameLB.height=nameSize.height;
    
    
    NSString *picurl = [NSString stringWithFormat:@"%@%@",[myDic objectForKey:@"picurl"],kProductImgThumbnailSuffix];
    [_imageIV sd_setImageWithURL:[NSURL URLWithString:picurl] placeholderImage:[UIImage imageNamed:@"default_goods"]];
    
}

#pragma mark - method
+(CGFloat)finalHeight
{
    return WFCGFloatY(78+10);
}
#pragma mark - life
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.imageIV];
        [self.contentView addSubview:self.nameLB];
        [self.contentView addSubview:self.priceLB];
        
        [self.contentView addSubview:self.countTF];
        [self.countTF addSubview:self.countLB];
    }
    return self;
}

#pragma mark - delegate
-(void)callback:(id)sender
{
    [self layoutSubviews];
}

@end
